package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.DictsortDetail;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DictsortDetailDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "类型名称")
    private String name;

    @ApiModelProperty(value = "字典类型编码")
    private String codeType;

    @ApiModelProperty(value = "键值")
    private Integer value;

    @ApiModelProperty(value = "备用字段")
    private String standby;

    @ApiModelProperty(value = "是否有效：0有效，1无效")
    private Integer status;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "借款类型金额")
    private Integer loanTypeMoney;

    @ApiModelProperty(value = "借款类型百分比")
    private String loanTypeAvg;


    public DictsortDetailDTO() {}

    public DictsortDetailDTO(DictsortDetail entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static DictsortDetailDTO convert(DictsortDetail entity) {
        return new DictsortDetailDTO(entity);
    }

    public static List<DictsortDetailDTO> convertList(List<DictsortDetail> list) {
        List<DictsortDetailDTO> resultList = new ArrayList<>();
        for (DictsortDetail entity : list) {
            resultList.add(new DictsortDetailDTO(entity));
        }
        return resultList;
    }}
